package com.lonely.web.controller.deliver;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lonely.common.core.domain.StatusInfo;
import com.lonely.common.core.domain.api.R;
import com.lonely.deliver.domain.dto.QueryOrderDeliverPageDTO;
import com.lonely.deliver.domain.vo.QueryOrderDeliverPageVO;
import com.lonely.deliver.domain.vo.QueryPdaScanSizeInfoVO;
import com.lonely.deliver.service.IOrderDeliverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 黄志标
 * @date: 2025/8/15 17:34
 * @description: 订单发货控制器
 */
@RestController
@RequestMapping("/orderDeliverManage/deliver")
@Api(tags = "发货管理/订单发货")
public class OrderDeliverController {

    @Autowired
    private IOrderDeliverService orderDeliverService;

    /**
     * 同步订单发货单数据
     *
     * @return
     */
    @GetMapping("/synchronizedOrderDeliver")
    public R<Boolean> synchronizedOrderDeliver() {
        this.orderDeliverService.synchronizedOrderDeliver();
        return R.status(true);
    }

    /**
     * 分页查询
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/page")
    @ApiOperation(value = "发货单分页查询")
    public R<Page<QueryOrderDeliverPageVO>> page(@RequestBody @Validated QueryOrderDeliverPageDTO queryDto) {
        return R.data(this.orderDeliverService.page(queryDto));
    }

    /**
     * 获取状态信息
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/getStatusInfo")
    public R<List<StatusInfo>> getStatusInfo(@RequestBody @Validated QueryOrderDeliverPageDTO queryDto) {
        return R.data(this.orderDeliverService.getStatusInfo(queryDto));
    }

    /**
     * 根据发货单id获取对应详情信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getDetail/{id}")
    public R<QueryOrderDeliverPageVO> getDetail(@PathVariable("id") Long id) {
        return R.data(this.orderDeliverService.getDetail(id));
    }

    /**
     * 查询该发货单的pda 扫描尺码信息
     *
     * @param id
     * @return
     */
    @GetMapping("/queryPdaScanSizeInfo/{id}")
    public R<List<QueryPdaScanSizeInfoVO>> queryPdaScanSizeInfo(@PathVariable("id") Long id) {
        return R.data(this.orderDeliverService.queryPdaScanSizeInfo(id));
    }

}
